﻿<?php

class Application_Form_Historique_HistoFilterForm extends Zend_Form {

	public function init() {
		$session = new Zend_Session_Namespace("codebar");
		$this->setName('createuser');

		$id = new Zend_Form_Element_Hidden('id');
		$id->addFilter('Int')
		->setDecorators(array('ViewHelper','FormErrors'));

		$u=Application_Model_RolesUsers::getMembres($session->user->getGroupeActif()->getID());
			
		$vendeur=new Zend_Form_Element_Select('vendeur');
		$vendeur->addMultiOption('RIEN', 'TOUS');
		foreach($u as $h)
		{
			$vendeur->addMultiOption($h->getLogin(),$h->getNom().' '.$h->getPrenom());
		}

		$vendeur->setLabel('Vendeur : ')
		->setRequired(false)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));


		$date_debut=new Zend_Form_Element_Text('datedebut');
		$date_debut->setLabel('Du :')
		->setRequired(false)
		->addFilter('StringTrim')
		->addValidator(new Zend_Validate_Date(array('format'=>'dd-mm-yyyy')));
		$date_debut	->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));

		$date_fin=new Zend_Form_Element_Text('datefin');
		$date_fin->setLabel('au :')
		->setRequired(false)
		->addFilter('StringTrim')
		->addValidator(new Zend_Validate_Date(array('format'=>'dd-mm-yyyy')));
		$date_fin->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));

		$categories=new Zend_Form_Element_MultiCheckbox('types');
		$categories->addMultiOptions(array('esp'=>'Espèces','CB'=>'CodeBar'));
		$categories->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$send = new Zend_Form_Element_Submit('send');
		$send->setAttrib('id','send_button')
		->setLabel('Filtrer')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$reset=new Zend_Form_Element_Reset('reset');
		$reset->setAttrib('class','button')
		->setLabel('Remise à zéro')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$this->addElements(array($id,$vendeur,$date_debut,$date_fin,$categories,$send,$reset));
	}

}
